             
import axios from  'axios'//引入axios
import {METHODS} from  './request'//



// 带配置项的 axios 实例  create
const instance  = axios.create({
    baseURL:"http://localhost:8080",   //封装 请求路径的 相同部分
    timeout:5000,    //5秒之内
})



// 抛出   函数调用  
export function request (method,url,params){
    switch(method){
        case METHODS.GET:
            return get(url,params)
        case METHODS.POST:
            console.log(params);
            return post(url,params)
    }
}



function get(url,params){
    return instance.get(url,params)
}


function post(url,params){
    console.log(params);
    return instance.post(url,params)
}